//  包装车险计费请求方法 (计费前判断订单数据是否改变)
import {store} from '@/store/index'
import {carValidator} from '@/utils/car_validator.ts'
 
function  toCharging(){
    let orderData = store.state['carFormStore']['orderData'];
    // 数据验证 （短路）
    if(!carValidator(orderData)){return}
    
    
    let orderDataHasChange = store.getters['carFormStore/orderDataHasChange'];
    let req = orderDataHasChange ? new Promise<any>((resolve, reject) =>{
         resolve(true)
    }) : store. dispatch('request', {url:'patch/orders/id', data:{}})
     
    return req.then( async() =>{
        let status:boolean
        await store.dispatch('request', {
            url: 'get/bill/id',
            data:{}
        }).then(success =>{ 
            status = success
        })
        return status
    })
     
}


export default toCharging
